﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Print_Print2c : System.Web.UI.Page
{
    _dbDataContext _db = new _dbDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["PhuLuc2cPrint"] != null)
            {
                try
                {
                    lbl_noidung.Text = Session["PhuLuc2cPrint"].ToString();
                    Session.Remove("PhuLuc2cPrint");
                    Response.Clear();
                    Response.AddHeader("content-disposition", "attachment; filename=Phuluc2c.xls");
                    Response.Charset = "";
                    Response.ContentType = "application/vnd.xls";
                    System.IO.StringWriter stringWrite = new System.IO.StringWriter();
                    System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
                    grid_Detail.RenderControl(htmlWrite);
                    Response.Write(stringWrite.ToString());
                    Response.End();
                    Response.Redirect("javascript:window.close()");
                }
                catch (Exception ex)
                {
                    Response.Write("<script>alert('" + ex.Message + "')</script>");
                }
                Session.Remove("PhuLuc2cPrint");
            }
        }
    }
}